package com.wsoft.email;

import cn.hutool.core.lang.Assert;
import com.wsoft.core.utils.EmailUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.wsoft.core.exception.Asserts.logger;

/**
 * @Author Zhang gukai
 * @Date 2024/11/27 10:43
 */


@Service
public class EmailServiceImpl implements EmailService {
    @Resource
    private EmailUtil emailUtil;

    @Override
    public boolean send(String to, String title, String content, String type) {
        boolean flag=false;
        //判断邮件发送信息是否为空
        Assert.notNull(to, "收件人信息不能为空");
        Assert.notNull(title, "邮件主题不能为空");
        Assert.notNull(content, "邮件正文不能为空");
        Assert.notNull(type, "邮件正文类型不能为空");
        emailUtil.sendEmail(to,title,content,type);
        flag=true;
        logger.info("发送邮件成功:{}->{}","574847016@qq.com",to);
        return flag;
    }
}
